﻿//
//
//

namespace Microsoft.OpenTurf.Silverlight
{
    using GalaSoft.MvvmLight;
    using Microsoft.Maps.MapControl;
    using Microsoft.OpenTurf.Silverlight.Common;
    using Microsoft.OpenTurf.Silverlight.Shared;
    using Microsoft.OpenTurf.Silverlight.ViewModel;
    using Microsoft.Practices.Unity;

    public class ViewModelLocator
    {
        #region Properties
        // Setup
        public static IUnityContainer Container
        {
            get;
            private set;
        }
        //Access
        public OpenTurfViewModelBase Login
        {
            get { return Container.Resolve<LoginViewModel>("Login"); }
        }
        public OpenTurfViewModelBase Main
        {
            get { return Container.Resolve<MainViewModel>("Main"); }
        }
        public OpenTurfViewModelBase Menu
        {
            get { return Container.Resolve<MenuViewModel>("Menu"); }
        }
        public OpenTurfViewModelBase Map
        {
            get { return Container.Resolve<MapViewModel>("Map"); }
        }
        public OpenTurfViewModelBase Search
        {
            get { return Container.Resolve<SearchViewModel>("Search"); }
        }
        #endregion

        /// <summary>
        /// Wire Up ViewModels for Resolution
        /// </summary>
        static ViewModelLocator()
        {
            Container = new UnityContainer();

            if (ViewModelBase.IsInDesignModeStatic)
            {
                // Load Up Design Time Data
            }
            else
            {
                // Wire up Runtime DataServices
            }

            Container.RegisterType(typeof(MainViewModel));
            Container.RegisterType(typeof(MapViewModel));
            Container.RegisterType(typeof(MenuViewModel));

            Container.RegisterType<IMenuView, MenuView>(new ContainerControlledLifetimeManager());
            Container.RegisterType<IMapView, MapView>(new ContainerControlledLifetimeManager());

            Container.RegisterType<IFeed, GenericFeed>();
            Container.RegisterType<IFeedItem, GenericFeedItem>();
            Container.RegisterType<Map, Map>();
        }

        /// <summary>
        /// Clean up 
        /// </summary>
        public static void Cleanup()
        {

        }


    }
}